#include <stdio.h>
#include<stdlib.h>
struct cell { //单链表结点结构体定义
 int x;
 struct cell* next;
};
struct cell* build(void) { //新建单链表，并将建好的单链表首结点地址返回
 struct cell* head,*tmp,*p;
 head= tmp = p = NULL;
 int n;
 scanf("%d",&n);
 while(n!=0){
    tmp=(struct cell*)malloc(sizeof(struct cell));
    tmp->x=n;
    
   tmp->next=NULL;
   if(head==NULL){
    head=tmp;
   }else{
    p->next=tmp;
   }
   p=tmp;
   scanf("%d",&n);
 }
 return head;//返回单链表头
}
void print(struct cell* head) {//打印整个单链表,head是指向单链表首结点的指针
 /*请在以下位置补充完整，实现函数print的功能
       ......
       ......
       ......
   */
  struct cell * a=head;
  while(a!=NULL){
    printf("%d ",a->x);
    a=a->next;
  }
}
void release(struct cell* head) {//释放单链表空间,head是指向单链表首结点的指针
 /*请在以下位置补充完整，实现函数release的功能
       ......
       ......
       ......
   */
  struct cell * a=head;
  while(a!=NULL){
    a=a->next;
    free(head);
    head=a;
  }
}
int main(void) {
 struct cell* head;
 head = build();
 if(head!=NULL)
        print(head);
    else
        printf("NULL");
 release(head);
}